const app = getApp()
Page({
  data: {
    display: "block",
    jilu: [0, 0, 0, 0, 0, 0, 0, 0, 0],
    flag: [0, 0, 0],
    zxflag: [],
    oneflag: false,
    twoflag: false,
    threeflag: false,
    fourflag: false,
    fiveflag: false,
    sixflag: false,
    sevenflag: false,
    // biaoji:1,
    tabbar: {},
    indicatorDots: true,
    autoplay: true,
    interval: 2000,
    imageList: [{
      "url": "http://sd.offcn.com/zg/wximg/2021/guoshengkao/two.png"
    }],
    winWidth: 0,
    currentTab: 0,
    list: [
      {
        title: '2022山东省考面试考情分析',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/one.png',
        lists: [{
            name: '山东省考面试考情（公安类）',
            sid: 58,
            biaoji: 1
          },
          {
            name: '山东省考面试考情（国安类）',
            sid: 59,
            biaoji: 1
          },
          {
            name: '山东省考面试考情（监狱类）',
            sid: 60,
            biaoji: 1
          },
          
          {
            name: '山东省考面试考情（戒毒类）',
            sid: 61,
            biaoji: 1
          },
          {
            name: '山东省考面试考情（综合类）',
            sid: 62,
            biaoji: 1
          }
        ]
      },
      {
        title: '冲刺30天',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/one.png',
        lists: [{
            name: '快记快学 稳扎稳打——行测30天冲分手册-学生版-91P',
            sid: 53,
            biaoji: 1
          },
          {
            name: '快记快学 稳扎稳打——行测30天冲分手册-答案版-29P',
            sid: 54,
            biaoji: 1
          },
          {
            name: '方向预判 热点推断——申论30天冲分手册-116p',
            sid: 55,
            biaoji: 1
          },
          
          {
            name: '严丝合缝“模”省考——2022省考还原模考题卷2-学生版-26P',
            sid: 56,
            biaoji: 1
          },
          {
            name: '严丝合缝“模”省考——2022省考还原模考题卷2-答案版-13P',
            sid: 57,
            biaoji: 1
          }
        ]
      },
      {
        title: '行政执法类1',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/one.png',
        lists: [
          // 行测-四项考点荟萃
          {
            name: '行政执法类政策分析',
            sid: 49,
            biaoji: 1
          },
          {
            name: '《行政处罚法》亮点解读',
            sid: 50,
            biaoji: 1
          },
          {
            name: '亮点解读答案及解析',
            sid: 51,
            biaoji: 1
          },
          {
            name: '一图看懂行政执法类岗位',
            sid: 52,
            biaoji: 1
          }
        ]
      },
      {
        title: '申论-习思想篇章',
        pdf: 'p2',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/f1.png',
        lists: [
          //申论-习思想篇章
          {
            name: '习近平新时代中国特色社会主义思想学习系列：坚持改善和保障民生',
            sid: 11,
            biaoji: 1

          },
          {
            name: '习近平新时代中国特色社会主义思想学习系列：人与自然和谐共生',
            sid: 12,
            biaoji: 1
          },
          {
            name: '习近平新时代中国特色社会主义思想学习系列：社会主义核心价值体系',
            sid: 13,
            biaoji: 1
          },
          {
            name: '习近平新时代中国特色社会主义思想学习系列：四个全面',
            sid: 14,
            biaoji: 1
          },
          {
            name: '习近平新时代中国特色社会主义思想学习系列：五位一体',
            sid: 15,
            biaoji: 1
          },
          {
            name: '习近平新时代中国特色社会主义思想学习系列：新发展理念',
            sid: 16,
            biaoji: 1
          },
        ]
      },
      {
        title: '申论范文',
        pdf: 'p1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/f1.png',
        lists: [{
            name: '第一章-申论范文卷1',
            sid: 1,
            biaoji: 1

          },
          {
            name: '第一章-申论范文卷2',
            sid: 2,
            biaoji: 1
          },
          {
            name: '第二章-申论范文卷3',
            sid: 3,
            biaoji: 1
          },
          {
            name: '第二章-申论范文卷4',
            sid: 4,
            biaoji: 1
          },
          {
            name: '第三章-申论范文卷5',
            sid: 5,
            biaoji: 1
          },
          {
            name: '第三章-申论范文卷6',
            sid: 6,
            biaoji: 1
          },
          {
            name: '第四章-申论范文卷7',
            sid: 7,
            biaoji: 1
          },
          {
            name: '第四章-申论范文卷8',
            sid: 8,
            biaoji: 1
          },
          {
            name: '第五章-申论范文卷9',
            sid: 9,
            biaoji: 1
          },
          {
            name: '第五章-申论范文卷10',
            sid: 10,
            biaoji: 1
          },


        ]
      },
      {
        title: '行测-典型易错5套题',
        pdf: 'p3',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/f1.png',
        lists: [
          //行测-典型易错5套题
          {
            name: '《典型易错题集-行测1》',
            sid: 17,
            biaoji: 1
          },
          {
            name: '《典型易错题集-行测2》',
            sid: 18,
            biaoji: 1
          },
          {
            name: '《典型易错题集-行测3》',
            sid: 19,
            biaoji: 1
          },
          {
            name: '《典型易错题集-行测4》',
            sid: 20,
            biaoji: 1
          },
          {
            name: '《典型易错题集-行测5》',
            sid: 21,
            biaoji: 1
          },
        ]
      },
      {
        title: '行测-解题思路拆解',
        pdf: 'p4',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/f1.png',
        lists: [

          // 行测-解题思路拆解
          {
            name: '《咬文嚼字——行测文科核心考点思路拆解》',
            sid: 22,
            biaoji: 1
          },
          {
            name: '《有条有理——行测理科核心考点思路拆解》',
            sid: 23,
            biaoji: 1
          },
          {
            name: '2022年山东省考行测判断推理常用的4大推理规则',
            sid: 24,
            biaoji: 1
          },
        ]
      },
      {
        title: '行测-四项考点荟萃',
        pdf: 'p5',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/f1.png',
        lists: [

          // 行测-四项考点荟萃
          {
            name: '地理常识（含答案）',
            sid: 25,
            biaoji: 1
          },
          {
            name: '法律常识（含答案）',
            sid: 26,
            biaoji: 1
          },
          {
            name: '历史常识',
            sid: 27,
            biaoji: 1
          },
          {
            name: '时政热点',
            sid: 28,
            biaoji: 1
          },
        ]
      },
      {
        title: '2022-图文攻略 · 申论',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/pdf.png',
        lists: [
          // 行测-四项考点荟萃
          {
            name: '《2022决“省”百日 图文攻略 · 申论-对策篇》',
            sid: 29,
            biaoji: 1
          },
          {
            name: '《2022决“省”百日 图文攻略 · 申论-分析篇》',
            sid: 30,
            biaoji: 1
          },
          {
            name: '《2022决“省”百日 图文攻略 · 申论-概括篇》',
            sid: 31,
            biaoji: 1
          },
          {
            name: '《2022决“省”百日 图文攻略 · 申论-贯彻篇》',
            sid: 32,
            biaoji: 1
          },
          {
            name: '《2022决“省”百日 图文攻略 · 申论-文章篇》',
            sid: 33,
            biaoji: 1
          },
        ]
      },
      {
        title: '2022-图文攻略· 行测',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/pdf.png',
        lists: [
          // 行测-四项考点荟萃
          {
            name: '“省”题再现——山东及多省公考行测精编200题',
            sid: 34,
            biaoji: 1
          },
          {
            name: '2022决“省”百日 图文攻略 · 行测-常识篇',
            sid: 35,
            biaoji: 1
          },
          {
            name: '2022决“省”百日 图文攻略 · 行测-判断篇',
            sid: 36,
            biaoji: 1
          },
          {
            name: '2022决“省”百日 图文攻略 · 行测-数量篇',
            sid: 37,
            biaoji: 1
          },
          {
            name: '2022决“省”百日 图文攻略 · 行测-言语篇',
            sid: 38,
            biaoji: 1
          },
          {
            name: '2022决“省”百日 图文攻略 · 行测-资料篇',
            sid: 39,
            biaoji: 1
          },
        ]
      },
      {
        title: '专题讲练系列',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/pdf.png',
        lists: [
          // 行测-四项考点荟萃
          {
            name: '核心考点专题精炼之申论',
            sid: 40,
            biaoji: 1
          },
          {
            name: '2022年山东省考核心考点专题精炼-判断推理',
            sid: 41,
            biaoji: 1
          },
          {
            name: '2022年山东省考核心考点专题精炼-数量关系',
            sid: 42,
            biaoji: 1
          },
          {
            name: '2022年山东省考核心考点专题精炼-言语理解',
            sid: 43,
            biaoji: 1
          },
          {
            name: '2022年山东省考核心考点专题精炼-资料分析',
            sid: 44,
            biaoji: 1
          }
        ]
      },
      {
        title: '行测解题技巧系列',
        pdf: 'f1',
        fm: 'https://sd.offcn.com/zg/wximg/2021/guoshengkao/one.png',
        lists: [
          // 行测-四项考点荟萃
          {
            name: '2022山东省考行测判断推理9个解题技巧',
            sid: 45,
            biaoji: 1
          },
          {
            name: '2022山东省考行测数量关系6个解题技巧',
            sid: 46,
            biaoji: 1
          },
          {
            name: '2022山东省考行测言语理解8个解题技巧',
            sid: 47,
            biaoji: 1
          },
          {
            name: '2022山东省考行测资料分析7个解题技巧',
            sid: 48,
            biaoji: 1
          }
        ]
      },
    ],
  },
  sczxone() {
    var _ = this
    _.setData({
      oneflag: !_.data.oneflag
    })
    wx.setStorage({
      key: "zxoneflag",
      data: _.data.oneflag,
    })
    console.log(_.data.oneflag)
  },
  sczxtwo() {
    var _ = this
    _.setData({
      twoflag: !_.data.twoflag
    })
    wx.setStorage({
      key: "zxtwoflag",
      data: _.data.twoflag,
    })
    console.log(_.data.twoflag)
  },
  sczxthree() {
    var _ = this
    _.setData({
      threeflag: !_.data.threeflag
    })
    wx.setStorage({
      key: "zxthreeflag",
      data: _.data.threeflag,
    })
    console.log(_.data.threeflag)
  },
  sczxfour() {
    var _ = this
    _.setData({
      fourflag: !_.data.fourflag
    })
    wx.setStorage({
      key: "zxfourflag",
      data: _.data.fourflag,
    })
    console.log(_.data.fourflag)
  },
  sczxfive() {
    var _ = this
    _.setData({
      fiveflag: !_.data.fiveflag
    })
    wx.setStorage({
      key: "zxfiveflag",
      data: _.data.fiveflag,
    })
    console.log(_.data.fiveflag)
  },
  sczxsix() {
    var _ = this
    _.setData({
      sixflag: !_.data.sixflag
    })
    wx.setStorage({
      key: "zxsixflag",
      data: _.data.sixflag,
    })
    console.log(_.data.sixflag)
  },
  sczxseven() {
    var _ = this
    _.setData({
      sevenflag: !_.data.sevenflag
    })
    wx.setStorage({
      key: "zxsevenflag",
      data: _.data.sevenflag,
    })
    console.log(_.data.sevenflag)
  },
  link1: function () {
    wx.navigateTo({
      url: '../link/link1/link1'
    })
  },
  link2: function () {
    wx.navigateTo({
      url: '../link/link2/link2'
    })
  },
  link3: function () {
    wx.navigateTo({
      url: '../link/link3/link3'
    })
  },
  link4: function () {
    wx.navigateTo({
      url: '../link/link4/link4'
    })
  },
  link5: function () {
    wx.navigateTo({
      url: '../link/link5/link5'
    })
  },
  link6: function () {
    wx.navigateTo({
      url: '../link/link6/link6'
    })
  },
  link7: function () {
    wx.navigateTo({
      url: '../link/link7/link7'
    })
  },
  topdf(e) {
    var _ = this;
    var phone = wx.getStorageSync('xzlphone')
    if (phone) {
      console.log(e.currentTarget.dataset.sid)
      var sid = e.currentTarget.dataset.sid;
      wx.navigateTo({
        url: '../pdf/pdf?sid=' + sid,
      })
    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 2000
      });
      _.setData({
        login: 1
      })
    }
  },
  shoucang(e) {
    var _ = this
    var phone = wx.getStorageSync('xzlphone')
    if (phone) {
      var i = e.currentTarget.dataset.sid
      console.log(e)
      console.log(i)
      var a = _.data.flag[i - 1]
      _.data.flag[i - 1] = !a
      //  console.log(_.data.flag)
      wx.setStorage({
        key: "shoucangarr",
        data: _.data.flag,
        success: function () {
          console.log('写入收藏数组成功')
        },
        fail: function () {
          console.log('写入收藏数组发生错误')
        }
      })
      var dataarr = _.data.list
      console.log(dataarr)
      for (var b = 0; b < _.data.flag.length; b++) {
        if (_.data.flag[b] == true) {
          for (var iii = 0; iii < _.data.list.length; iii++) {
            if (_.data.list[iii].lists.sid == b + 1) {
              _.data.list[iii].lists[b] = 0
            }
            // console.log(_.data.list[iii].biaoji)
          }
          // dataarr[0].lists[b].biaoji=0
          // console.log(dataarr[0].lists[b].biaoji)
        }
        // if (_.data.flag[b] == false || _.data.flag[b] == 0) {
        //   console.log(b)
        //   dataarr[0].lists[b].biaoji = 1
        //   console.log(dataarr[0].lists[b].biaoji)
        // }
      }
      _.setData({
        list: dataarr
      })
      wx.setStorage({
        key: "listbc",
        data: _.data.list,
        success: function () {
          console.log('写入数组成功')
        },
        fail: function () {
          console.log('写入数组发生错误')
        }
      })

    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 2000
      });
      _.setData({
        login: 1
      })
    }

  },
  swipclick0() {
    wx.navigateToMiniProgram({
      appId: 'wxca86930ec3e80717',
      path: 'page/course/details?scode=&id=359751',
      envVersion: 'release', // 打开正式版

    })
  },
  swipclick1() {
    wx.navigateToMiniProgram({
      appId: 'wxca86930ec3e80717',
      path: 'page/course/details?scode=&id=359751',
      envVersion: 'release', // 打开正式版

    })
  },
  swipclick: function (e) { //点击图片触发事件
    // console.log(this.data.imageList[this.data.current].url);
    // console.log(e)
    var _ = this
    var phone = wx.getStorageSync('xzlphone')
    if (phone) {
      if (this.data.imageList[this.data.current].url == 'http://sd.offcn.com/zg/wximg/2021/guoshengkao/one.png') {
        wx.navigateToMiniProgram({
          appId: 'wxca86930ec3e80717',
          path: '',
          envVersion: 'release', // 打开正式版

        })
      }
      if (this.data.imageList[this.data.current].url == 'http://sd.offcn.com/zg/wximg/2021/guoshengkao/two.png') {
        wx.navigateToMiniProgram({
          appId: 'wxca86930ec3e80717',
          path: '',
          envVersion: 'release', // 打开正式版

        })
      }
      if (this.data.imageList[this.data.current].url == 'http://sd.offcn.com/zg/wximg/2021/guoshengkao/three.png') {
        wx.navigateToMiniProgram({
          appId: 'wxca86930ec3e80717',
          path: '',
          envVersion: 'release', // 打开正式版

        })
      }

    } else {
      wx.showToast({
        title: '请先登录',
        icon: 'none',
        duration: 2000
      });
      _.setData({
        login: 1
      })
    }


  },
  bindchange: function (e) { //轮播图发生改变
    this.setData({
      current: e.detail.current
    })
  },
  swichNav: function (e) {

    var _ = this;

    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      _.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  index() {
    wx.redirectTo({
      url: '../index/index',
    })
  },
  my() {
    wx.redirectTo({
      url: '../my/my',
    })
  },
  bindChanget: function (e) {

    var _ = this;
    _.setData({
      currentTab: e.detail.current
    });

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _ = this;
    console.log(options);
    _.setData({
      area: options.area,
      geneal: options.agent
    })
    if (options.page) {
      _.setData({
        page: options.page
      })
    }
    var list = wx.getStorageSync('listbc')
    console.log(list)
    if (list != '') {
      _.setData({
        list: list
      })
    }
    var sczhuangtai = wx.getStorageSync('shoucangarr')
    console.log(sczhuangtai)
    if (sczhuangtai != '') {
      _.setData({
        flag: sczhuangtai
      })
    }

    wx.setStorageSync('list', _.data.list)
    var oneflag = wx.getStorageSync('zxoneflag')
    var twoflag = wx.getStorageSync('zxtwoflag')
    var threeflag = wx.getStorageSync('zxthreeflag')
    _.setData({
      oneflag: oneflag,
      twoflag: twoflag,
      threeflag: threeflag
    })
  },
  getPhoneNumber(e) {
    var _ = this;
    wx.cloud.callFunction({
      name: 'getMobile',
      data: {
        weRunData: wx.cloud.CloudID(e.detail.cloudID),
      }
    }).then(res => {
      _.setData({
        mobile: res.result,
      })
      console.log(res.result)
      wx.setStorageSync('xzlphone', res.result)
      wx.request({
        url: 'https://tgadmin.sdwx.zgkfpt.cn/api/v1/collect_v3',
        method: 'POST',
        data: {
          activeId: 39,
          mobile: res.result,
          areaCode: _.data.area,
          agent: _.data.geneal,
          pageId: _.data.page
        },
        success: res => {
          console.log(res);
        }
      })
      // wx.setStorageSync('xzlphone', _.data.mobile)
      wx.request({ //发送请求
        url: 'https://zg99.offcn.com/index/biaodan/register?actid=43819&callback=?', //接收url
        data: {
          phone: _.data.mobile,
          fenxiao: _.data.area,
          geneal: _.data.geneal,
        }, //接收参数
        success(res) {
          var jsonStr = res.data;
          jsonStr = jsonStr.replace("(", "");
          jsonStr = jsonStr.replace(")", "");
          if (typeof jsonStr != 'object') {
            jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
            var theJson = JSON.parse(jsonStr);
          }
          console.log(theJson)
          _.setData({
            login: 0,
            display: "none"
          })
        }
      });



    })

  },

  //选择条目
  tabSelect(e) {
    console.log(e.currentTarget.dataset.id)
    this.setData({
      list: e.currentTarget.dataset.id,
      tabCur: e.currentTarget.dataset.id,
      scrollLeft: (e.currentTarget.dataset.id - 2) * 200
    })
  },
  getUserProfile(e) {

  },
  // /**
  //  * 生命周期函数--监听页面初次渲染完成
  //  */
  onReady: function () {
    // app.hidetabbar()
  },

  // /**
  //  * 生命周期函数--监听页面显示
  //  */
  onShow: function () {
    // app.hidetabbar()
  }

})